<?php
# Part of RASS unittest fixtures: hidden files and dirs.
# Copyright (C) 2008 rambla.be
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

class RassInvalidAccessTest extends UnitTestCase {
    function TestRassClientlib() {
        $this->UnitTestCase("Invalid Access Tests");
    }

    // function testSetup() {
    //   try {
    //     $rass = new Rass(SUPERUSER, SUPERPWD, BASE);
    //     $newUser = $rass->createUser(USER, EMAIL, PWD);
    //     # create a subdir
    //     $rass = new Rass(USER, PWD, BASE);
    //   }
    //   catch(Zend_Gdata_App_Exception $e) {
    //     assert(False);
    //   }
    // }

    function testCreateHiddenDir() {
      $status = 0;
      try {
        $rass = new Rass(USER, PWD, BASE);
        $rass->setSSL(SSL);
        $entry = $rass->createDir(".chiquita");
      }
      catch(Zend_Gdata_App_Exception $e) {
        $status = $e->getResponse()->getStatus();
      }
      $this->assertEqual($status, 403); 
    }

    function testGetHiddenItem() {
      $status = 0;
      try {
        $rass = new Rass(NORMAL_USER, NORMAL_PWD, BASE);
        $rass->setSSL(SSL);
        $entry = $rass->getItemHeader(HIDDEN_FILE);
      }
      catch(Zend_Gdata_App_Exception $e) {
        $status = $e->getResponse()->getStatus();
      }
      $this->assertEqual($status, 403); 
    }

    function testDeleteHiddenItem() {
      $status = 0;
      try {
        $rass = new Rass(NORMAL_USER, NORMAL_PWD, BASE);
        $rass->setSSL(SSL);
        $entry = $rass->deleteItem(HIDDEN_FILE);
      }
      catch(Zend_Gdata_App_Exception $e) {
        $status = $e->getResponse()->getStatus();
      }
      $this->assertEqual($status, 403); 
    }
    
    function testCreateNotHiddenDir() {
      $status = 0;
      try {
        $rass = new Rass(USER, PWD, BASE);
        $rass->setSSL(SSL);
        $entry = $rass->createDir("not.hidden");
        $this->assertEqual($rass->getResponse()->getStatus(), 201); 
        $rass->deleteDir("not.hidden");
        $this->assertEqual($rass->getResponse()->getStatus(), 204); 
      }
      catch(Zend_Gdata_App_Exception $e) {
        assert(false);
      }
    }

    # THESE HAVEN'T BEEN ADDED YET
    //     function testNameConventions() {
    //       $rc = new RawsConnection(USER, PWD);
    //       // PUT the sub-dir 'rass unittest'
    //       $rc->sendRequest(BASE . "dir/" . 'rass%20unittest', "PUT");
    //       $this->assertEqual($rc->getHttpCode(), 400);
    //       // DELETE the sub-dir 'rass unittest'
    //       $rc->sendRequest(BASE . "dir/" . 'rass%20unittest', "DELETE");
    //       $this->assertEqual($rc->getHttpCode(), 400);
    //       // GET the sub-dir 'rass unittest'
    //       $rc->sendRequest(BASE . "dir/" . 'rass%20unittest', "GET");
    //       $this->assertEqual($rc->getHttpCode(), 404);
    //       // GET items for 'rass unittest'
    //       $rc->sendRequest(BASE . "item/" . 'rass%20unittest', "GET");
    //       $this->assertEqual($rc->getHttpCode(), 404);
    //       // GET item for 'rass unittest'
    //       $rc->sendRequest(BASE . "item/" . 'bla%20bla.mp4', "HEAD");
    //       $this->assertEqual($rc->getHttpCode(), 404);
    //       // GET item for 'rass unittest'
    //       $rc->sendRequest(BASE . "item/" . 'bla%20bla.mp4', "GET");
    //       $this->assertEqual($rc->getHttpCode(), 404);
    //       // PUT item for 'rass unittest'
    //       $rc->sendRequest(BASE . "item/" . 'bla%20bla.mp4', "PUT");
    //       $this->assertEqual($rc->getHttpCode(), 400);
    //     }

    // function testTeardown() {
    //   try {
    //     $rass = new Rass(USER, PWD, BASE);
    //     $rass = new Rass(SUPERUSER, SUPERPWD, BASE);
    //     $newUser = $rass->deleteUser(USER);
    //   }
    //   catch(Zend_Gdata_App_Exception $e) {
    //     assert(False);
    //   }
    // }
    
}